<div class="subhead">Register</div>
<div class="bodywrap">
  <div class="cont">
  	<div class="formcss">
  <?php $form=$this->beginWidget('CActiveForm', array(
	'id'=>'user',
	'clientOptions' => array(
				'onsubmit' => true,
			),
)); ?>
       	<?php echo $form->error($model,'username'); ?>	
		<?php echo $form->textField($model,'username',array('value'=>'Email Address','onfocus'=>'setfields("Users_username")')); ?>
		
       <?php echo $form->error($model,'password'); ?>
		<?php echo $form->textField($model,'password',array('value'=>'Password','onfocus'=>'setfields("Users_password")')); ?>
	    <div class="errormessage" id="retype"></div>
      <input type="text" id="Users_password2" value="Re-Type Password" onfocus="setfields('Users_password2')">
		  
    <input type="hidden" id="phone_number" name="phone_number" value="0"/>
        <div class="button">
         <?php echo CHtml::submitButton('Register',array('class'=>'login','onclick'=>'return checkpassword()')); ?>
        </div>
        <?php $this->endWidget(); ?>
      </div> 
    </div>
    <div class="regi"><a href="<?php echo ApplicationConfig::getURL('', 'site', 'login');?>">Sign in</a></div>
    </div>

<script type="text/javascript">
function setfields(id)
{
	var input = document.getElementById(id);
  input.value="";
	if(id=="Users_password" || id=="Users_password2")
	{
		//document.getElementById($id).type="password";   //not workin in IE
		var input2= input.cloneNode(false);
	    input2.setAttribute('type','password');
	    input2.setAttribute('value','');
	    input2.setAttribute('onfocus','');
	    input.parentNode.replaceChild(input2,input);
	    input2.focus();
	}
}
function checkpassword()
{
   pass1=document.getElementById("Users_password").value;
   pass2=document.getElementById("Users_password2").value;
   if(pass1==pass2){
    return true;
    }
    else{
     
    document.getElementById('retype').innerHTML="Re-type password must be same as password";
    return false;
     }

}
function savephonenumber(phone_number)
{ 
    document.getElementById("phone_number").value=phone_number;
}
</script>
